package com.exchange.Public;

import android.content.Context;
import android.graphics.drawable.Drawable;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

public class o
{
  private static final String a = ExchangeConstants.LOG_TAG + "_network";

  public static Drawable a(Context paramContext, String paramString)
  {
    Object localObject1;
    Object localObject2;
    String str1;
    String str3;
    if ((paramString == null) || ("".equals(paramString)))
      localObject1 = null;
    do
    {
      return localObject1;
      localObject1 = b(paramContext, paramString);
    }
    while (localObject1 != null);
    try
    {
      int i = paramString.lastIndexOf(".");
      if (i != -1)
      {
        str1 = paramString.substring(i);
        String str2 = str1 + ".tmp";
        str3 = m.a(paramString) + str2;
        if (h.b())
        {
          new File(ExchangeConstants.a).mkdirs();
          label276: localObject2 = new File(ExchangeConstants.a, str3);
        }
      }
    }
    catch (Exception localException2)
    {
      try
      {
        byte[] arrayOfByte;
        int j;
        Object localObject3 = new FileOutputStream((File)localObject2);
        while (true)
        {
          while (true)
          {
            InputStream localInputStream = (InputStream)new URL(paramString).openConnection().getContent();
            arrayOfByte = new byte[4096];
            j = localInputStream.read(arrayOfByte);
            if (j != -1)
              break label276;
            ((FileOutputStream)localObject3).flush();
            localInputStream.close();
            ((FileOutputStream)localObject3).close();
            File localFile2 = new File(((File)localObject2).getParent(), ((File)localObject2).getName().replace(".tmp", ""));
            ((File)localObject2).renameTo(localFile2);
            Drawable localDrawable = Drawable.createFromPath(localFile2.getAbsolutePath());
            localObject1 = localDrawable;
          }
          FileOutputStream localFileOutputStream = paramContext.openFileOutput(str3, 3);
          File localFile1 = paramContext.getFileStreamPath(str3);
          localObject2 = localFile1;
          localObject3 = localFileOutputStream;
        }
        ((FileOutputStream)localObject3).write(arrayOfByte, 0, j);
      }
      catch (Exception localException2)
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              n.a(a, localException1.getStackTrace().toString() + "urlString:\t" + paramString);
              if ((localObject2 != null) && (((File)localObject2).exists()))
                ((File)localObject2).deleteOnExit();
              localObject1 = null;
            }
            localException2 = localException2;
            localObject2 = null;
          }
          str1 = "";
        }
      }
    }
  }

  // ERROR //
  private static String a(InputStream paramInputStream)
  {
    // Byte code:
    //   0: new 173	java/io/BufferedReader
    //   3: dup
    //   4: new 175	java/io/InputStreamReader
    //   7: dup
    //   8: aload_0
    //   9: invokespecial 178	java/io/InputStreamReader:<init>	(Ljava/io/InputStream;)V
    //   12: sipush 8192
    //   15: invokespecial 181	java/io/BufferedReader:<init>	(Ljava/io/Reader;I)V
    //   18: astore_1
    //   19: new 10	java/lang/StringBuilder
    //   22: dup
    //   23: invokespecial 182	java/lang/StringBuilder:<init>	()V
    //   26: astore_2
    //   27: aload_1
    //   28: invokevirtual 185	java/io/BufferedReader:readLine	()Ljava/lang/String;
    //   31: astore 8
    //   33: aload 8
    //   35: ifnonnull +16 -> 51
    //   38: aload_0
    //   39: invokevirtual 113	java/io/InputStream:close	()V
    //   42: aload_2
    //   43: invokevirtual 35	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   46: astore 5
    //   48: aload 5
    //   50: areturn
    //   51: aload_2
    //   52: new 10	java/lang/StringBuilder
    //   55: dup
    //   56: aload 8
    //   58: invokestatic 21	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   61: invokespecial 25	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   64: ldc 187
    //   66: invokevirtual 31	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   69: invokevirtual 35	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   72: invokevirtual 31	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   75: pop
    //   76: goto -49 -> 27
    //   79: astore 6
    //   81: getstatic 37	com/exchange/Public/o:a	Ljava/lang/String;
    //   84: ldc 189
    //   86: aload 6
    //   88: invokestatic 192	com/exchange/Public/n:b	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Exception;)V
    //   91: aload_0
    //   92: invokevirtual 113	java/io/InputStream:close	()V
    //   95: aconst_null
    //   96: astore 5
    //   98: goto -50 -> 48
    //   101: astore 7
    //   103: getstatic 37	com/exchange/Public/o:a	Ljava/lang/String;
    //   106: ldc 189
    //   108: aload 7
    //   110: invokestatic 192	com/exchange/Public/n:b	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Exception;)V
    //   113: aconst_null
    //   114: astore 5
    //   116: goto -68 -> 48
    //   119: astore_3
    //   120: aload_0
    //   121: invokevirtual 113	java/io/InputStream:close	()V
    //   124: aload_3
    //   125: athrow
    //   126: astore 4
    //   128: getstatic 37	com/exchange/Public/o:a	Ljava/lang/String;
    //   131: ldc 189
    //   133: aload 4
    //   135: invokestatic 192	com/exchange/Public/n:b	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Exception;)V
    //   138: aconst_null
    //   139: astore 5
    //   141: goto -93 -> 48
    //   144: astore 10
    //   146: getstatic 37	com/exchange/Public/o:a	Ljava/lang/String;
    //   149: ldc 189
    //   151: aload 10
    //   153: invokestatic 192	com/exchange/Public/n:b	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Exception;)V
    //   156: aconst_null
    //   157: astore 5
    //   159: goto -111 -> 48
    //
    // Exception table:
    //   from	to	target	type
    //   27	33	79	java/io/IOException
    //   51	76	79	java/io/IOException
    //   91	95	101	java/io/IOException
    //   27	33	119	finally
    //   51	76	119	finally
    //   81	91	119	finally
    //   120	124	126	java/io/IOException
    //   38	42	144	java/io/IOException
  }

  // ERROR //
  public static String a(String paramString1, String paramString2)
  {
    // Byte code:
    //   0: new 197	java/util/Random
    //   3: dup
    //   4: invokespecial 198	java/util/Random:<init>	()V
    //   7: sipush 1000
    //   10: invokevirtual 202	java/util/Random:nextInt	(I)I
    //   13: istore_2
    //   14: ldc 204
    //   16: invokestatic 209	java/lang/System:getProperty	(Ljava/lang/String;)Ljava/lang/String;
    //   19: astore_3
    //   20: getstatic 37	com/exchange/Public/o:a	Ljava/lang/String;
    //   23: new 10	java/lang/StringBuilder
    //   26: dup
    //   27: iload_2
    //   28: invokestatic 211	java/lang/String:valueOf	(I)Ljava/lang/String;
    //   31: invokespecial 25	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   34: ldc 213
    //   36: invokevirtual 31	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   39: aload_1
    //   40: invokevirtual 31	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   43: aload_3
    //   44: invokevirtual 31	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   47: aload_0
    //   48: invokevirtual 31	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   51: invokevirtual 35	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   54: invokestatic 162	com/exchange/Public/n:a	(Ljava/lang/String;Ljava/lang/String;)V
    //   57: new 215	org/apache/http/client/methods/HttpPost
    //   60: dup
    //   61: aload_1
    //   62: invokespecial 216	org/apache/http/client/methods/HttpPost:<init>	(Ljava/lang/String;)V
    //   65: astore 4
    //   67: new 218	org/apache/http/params/BasicHttpParams
    //   70: dup
    //   71: invokespecial 219	org/apache/http/params/BasicHttpParams:<init>	()V
    //   74: astore 5
    //   76: aload 5
    //   78: sipush 10000
    //   81: invokestatic 225	org/apache/http/params/HttpConnectionParams:setConnectionTimeout	(Lorg/apache/http/params/HttpParams;I)V
    //   84: aload 5
    //   86: sipush 20000
    //   89: invokestatic 228	org/apache/http/params/HttpConnectionParams:setSoTimeout	(Lorg/apache/http/params/HttpParams;I)V
    //   92: new 230	org/apache/http/impl/client/DefaultHttpClient
    //   95: dup
    //   96: aload 5
    //   98: invokespecial 233	org/apache/http/impl/client/DefaultHttpClient:<init>	(Lorg/apache/http/params/HttpParams;)V
    //   101: astore 6
    //   103: getstatic 237	com/exchange/Public/ExchangeConstants:DATA_COMPRESS	Z
    //   106: ifeq +201 -> 307
    //   109: new 10	java/lang/StringBuilder
    //   112: dup
    //   113: ldc 239
    //   115: invokespecial 25	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   118: aload_0
    //   119: invokevirtual 31	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   122: invokevirtual 35	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   125: invokestatic 242	com/exchange/Public/h:b	(Ljava/lang/String;)[B
    //   128: astore 18
    //   130: aload 4
    //   132: ldc 244
    //   134: ldc 246
    //   136: invokevirtual 249	org/apache/http/client/methods/HttpPost:addHeader	(Ljava/lang/String;Ljava/lang/String;)V
    //   139: aload 4
    //   141: new 251	org/apache/http/entity/InputStreamEntity
    //   144: dup
    //   145: new 253	java/io/ByteArrayInputStream
    //   148: dup
    //   149: aload 18
    //   151: invokespecial 256	java/io/ByteArrayInputStream:<init>	([B)V
    //   154: getstatic 259	com/exchange/Public/h:b	I
    //   157: i2l
    //   158: invokespecial 262	org/apache/http/entity/InputStreamEntity:<init>	(Ljava/io/InputStream;J)V
    //   161: invokevirtual 266	org/apache/http/client/methods/HttpPost:setEntity	(Lorg/apache/http/HttpEntity;)V
    //   164: aload 6
    //   166: aload 4
    //   168: invokeinterface 272 2 0
    //   173: astore 12
    //   175: aload 12
    //   177: invokeinterface 278 1 0
    //   182: invokeinterface 284 1 0
    //   187: sipush 200
    //   190: if_icmpne +217 -> 407
    //   193: aload 12
    //   195: invokeinterface 288 1 0
    //   200: astore 13
    //   202: aload 13
    //   204: ifnull +197 -> 401
    //   207: aload 13
    //   209: invokeinterface 293 1 0
    //   214: astore 14
    //   216: aload 12
    //   218: ldc 244
    //   220: invokeinterface 297 2 0
    //   225: astore 15
    //   227: aload 15
    //   229: ifnull +259 -> 488
    //   232: aload 15
    //   234: invokeinterface 302 1 0
    //   239: ldc 246
    //   241: invokevirtual 306	java/lang/String:equalsIgnoreCase	(Ljava/lang/String;)Z
    //   244: ifeq +244 -> 488
    //   247: new 308	java/util/zip/InflaterInputStream
    //   250: dup
    //   251: aload 14
    //   253: invokespecial 309	java/util/zip/InflaterInputStream:<init>	(Ljava/io/InputStream;)V
    //   256: astore 16
    //   258: aload 16
    //   260: invokestatic 311	com/exchange/Public/o:a	(Ljava/io/InputStream;)Ljava/lang/String;
    //   263: astore 17
    //   265: getstatic 37	com/exchange/Public/o:a	Ljava/lang/String;
    //   268: new 10	java/lang/StringBuilder
    //   271: dup
    //   272: iload_2
    //   273: invokestatic 211	java/lang/String:valueOf	(I)Ljava/lang/String;
    //   276: invokespecial 25	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   279: ldc_w 313
    //   282: invokevirtual 31	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   285: aload_3
    //   286: invokevirtual 31	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   289: aload 17
    //   291: invokevirtual 31	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   294: invokevirtual 35	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   297: invokestatic 162	com/exchange/Public/n:a	(Ljava/lang/String;Ljava/lang/String;)V
    //   300: aload 17
    //   302: astore 8
    //   304: goto +191 -> 495
    //   307: new 315	java/util/ArrayList
    //   310: dup
    //   311: iconst_1
    //   312: invokespecial 318	java/util/ArrayList:<init>	(I)V
    //   315: astore 10
    //   317: aload 10
    //   319: new 320	org/apache/http/message/BasicNameValuePair
    //   322: dup
    //   323: ldc_w 322
    //   326: aload_0
    //   327: invokespecial 323	org/apache/http/message/BasicNameValuePair:<init>	(Ljava/lang/String;Ljava/lang/String;)V
    //   330: invokeinterface 328 2 0
    //   335: pop
    //   336: aload 4
    //   338: new 330	org/apache/http/client/entity/UrlEncodedFormEntity
    //   341: dup
    //   342: aload 10
    //   344: ldc_w 332
    //   347: invokespecial 335	org/apache/http/client/entity/UrlEncodedFormEntity:<init>	(Ljava/util/List;Ljava/lang/String;)V
    //   350: invokevirtual 266	org/apache/http/client/methods/HttpPost:setEntity	(Lorg/apache/http/HttpEntity;)V
    //   353: goto -189 -> 164
    //   356: astore 9
    //   358: aload 9
    //   360: invokevirtual 338	org/apache/http/client/ClientProtocolException:printStackTrace	()V
    //   363: getstatic 37	com/exchange/Public/o:a	Ljava/lang/String;
    //   366: new 10	java/lang/StringBuilder
    //   369: dup
    //   370: iload_2
    //   371: invokestatic 211	java/lang/String:valueOf	(I)Ljava/lang/String;
    //   374: invokespecial 25	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   377: ldc_w 340
    //   380: invokevirtual 31	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   383: aload_1
    //   384: invokevirtual 31	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   387: invokevirtual 35	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   390: aload 9
    //   392: invokestatic 343	com/exchange/Public/n:c	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Exception;)V
    //   395: aconst_null
    //   396: astore 8
    //   398: goto +97 -> 495
    //   401: aconst_null
    //   402: astore 8
    //   404: goto +91 -> 495
    //   407: getstatic 37	com/exchange/Public/o:a	Ljava/lang/String;
    //   410: new 10	java/lang/StringBuilder
    //   413: dup
    //   414: iload_2
    //   415: invokestatic 211	java/lang/String:valueOf	(I)Ljava/lang/String;
    //   418: invokespecial 25	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   421: ldc_w 345
    //   424: invokevirtual 31	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   427: aload_1
    //   428: invokevirtual 31	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   431: invokevirtual 35	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   434: invokestatic 347	com/exchange/Public/n:c	(Ljava/lang/String;Ljava/lang/String;)V
    //   437: aconst_null
    //   438: astore 8
    //   440: goto +55 -> 495
    //   443: astore 7
    //   445: aload 7
    //   447: invokevirtual 348	java/io/IOException:printStackTrace	()V
    //   450: getstatic 37	com/exchange/Public/o:a	Ljava/lang/String;
    //   453: new 10	java/lang/StringBuilder
    //   456: dup
    //   457: iload_2
    //   458: invokestatic 211	java/lang/String:valueOf	(I)Ljava/lang/String;
    //   461: invokespecial 25	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   464: ldc_w 350
    //   467: invokevirtual 31	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   470: aload_1
    //   471: invokevirtual 31	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   474: invokevirtual 35	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   477: aload 7
    //   479: invokestatic 343	com/exchange/Public/n:c	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Exception;)V
    //   482: aconst_null
    //   483: astore 8
    //   485: goto +10 -> 495
    //   488: aload 14
    //   490: astore 16
    //   492: goto -234 -> 258
    //   495: aload 8
    //   497: areturn
    //
    // Exception table:
    //   from	to	target	type
    //   103	353	356	org/apache/http/client/ClientProtocolException
    //   407	437	356	org/apache/http/client/ClientProtocolException
    //   103	353	443	java/io/IOException
    //   407	437	443	java/io/IOException
  }

  public static Drawable b(Context paramContext, String paramString)
  {
    Object localObject;
    String str1;
    Drawable localDrawable1;
    if ((paramString == null) || ("".equals(paramString)))
    {
      localObject = null;
      return localObject;
    }
    try
    {
      int i = paramString.lastIndexOf(".");
      if (i != -1)
      {
        str1 = paramString.substring(i);
        String str2 = m.a(paramString) + str1;
        localDrawable1 = Drawable.createFromPath(ExchangeConstants.a + str2);
        if (localDrawable1 == null)
        {
          Drawable localDrawable2 = Drawable.createFromPath(paramContext.getFilesDir().getAbsolutePath() + "/" + str2);
          localObject = localDrawable2;
        }
      }
    }
    catch (Exception localException)
    {
      while (true)
      {
        while (true)
        {
          while (true)
          {
            n.a(a, localException.getStackTrace().toString());
            localObject = null;
          }
          localObject = localDrawable1;
        }
        str1 = "";
      }
    }
  }
}